#ifndef MODEL_HPP
#define MODEL_HPP

#include "Common.hpp"

#include <list>
#include <vector>

class Object;
class Material;
class objLoader;

class Box {
public:
  vec3 pos;
  vec3 dis;
  bool isCylinder;
  
  vec3 min() {return (pos - dis); }
  vec3 max() {return (pos + dis); }
};

class Model
{
public: 
  Model(const std::string & filename);
  ~Model();
    
  void draw();

  Box m_bounds;
  
  void attachParent(Object * obj);
  size_t detachParent(Object * obj);
  
  objLoader * m_objLoader;
 
  GLuint m_vaoHandle;
 
  enum VboHandle {
    Vertices, Normals, TexCoords, NumVbos
  };
  
  GLuint m_vboHandles[NumVbos];
  
  GLint m_al_vertex;
  GLint m_al_normal;  
  GLint m_al_texCoord;
  
  GLint m_ul_Ka;  
  GLint m_ul_Kd;    
  GLint m_ul_Ks;   
  GLint m_ul_s;
  
  GLint m_ul_model;    
  GLint m_ul_texMap;   
  
  int m_materialCount;
  Material * m_materials;
  
  std::list<Object*> m_parents;
  
};

#endif // MODEL_HPP
